x <- seq(0,15, length.out=100)

y1 <- dgamma(x, shape=1, rate=1)

y2 <- dgamma(x, shape=2, rate=1)
y3 <- dgamma(x, shape=5, rate=0.5)

plot(x, y1, type='l', col='blue', lwd=2, main='Gamma distribution', xlab='x',
     ylab='density', ylim=c(0, max(y1, y2, y3)))

lines(x, y2, col='red', lwd=2)

lines(x, y3, col='green', lwd=2)

# plot.new()
legend('topright', legend = c("Shape=1, rate=1", "Shape=2, rate=1", "Shape=5, rate=0.5"),
       col=c("blue", "red", "green"), lwd=2)


